//
//  RechargeNetworkCell.swift
//  SCA
//
//  Created by tjun on 2025/9/15.
//

import UIKit

struct RechargeModel {
    let network: String
    let address: String
    let detail: String
    let hint: String
    let qrCodeLink: String
}

class RechargeNetworkView: UIView {
    
    let nameLabel = UILabel(font: UIFontSemiboldMake(18), textColor: .white)
    let detailLabel = UILabel(textColor: .white)
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        nameLabel.addTo(self)
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(AppStyle.margin.left)
            make.top.equalTo(AppStyle.margin.left)
        }
        
        detailLabel.addTo(self)
        detailLabel.numberOfLines = 0
        detailLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(AppStyle.margin.left)
            make.top.equalTo(nameLabel.snp.bottom).offset(12)
            make.bottom.equalTo(-AppStyle.margin.right)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

class RechargeNetworkCell: BaseTableViewCell {
    
    let networkView = RechargeNetworkView()
    
    var model: RechargeModel! {
        didSet {
            networkView.nameLabel.text = model.network
            networkView.detailLabel.attributedText = model.detail.titleMargin(3, font: UIFontMediumMake(12), alignment: .left)
        }
    }
    
    override func setSubView() {
        super.setSubView()
        
        selectionStyle = .none
        self.backgroundColor = AppStyle.color.background
        
        networkView.addTo(self.contentView)
        networkView.layer.cornerRadius = 10
        networkView.layer.masksToBounds = true
        networkView.layer.borderWidth = 1
        networkView.layer.borderColor = UIColorMake(0xD2D2D2).cgColor
        networkView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(AppStyle.margin.left)
            make.top.equalTo(AppStyle.margin.left)
            make.bottom.equalToSuperview()
        }
        
    }
}

 
